function readURL(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();
        reader.onload = function(e) {
            $("#demo1").attr("src", e.target.result)
        };
        reader.readAsDataURL(input.files[0])
    }
}
$("#imgInp").change(function() {
    $("#small_img_div").css("display", "block");
    readURL(this)
});
var imgsObj = $(".amplifyImg img");
if (imgsObj) {
    $.each(imgsObj,
        function() {
            $(this).click(function() {
                var currImg = $(this);
                coverLayer(1);
                var tempContainer = $("<div class=tempContainer></div>");
                with(tempContainer) {
                    appendTo("body");
                    var windowWidth = $(window).width();
                    var windowHeight = $(window).height();
                    var orignImg = new Image();
                    orignImg.src = currImg.attr("src");
                    var currImgWidth = orignImg.width;
                    var currImgHeight = orignImg.height;
                    if (currImgWidth < windowWidth) {
                        if (currImgHeight < windowHeight) {
                            var topHeight = (windowHeight - currImgHeight) / 2;
                            if (topHeight > 35) {
                                topHeight = topHeight - 35;
                                css("top", topHeight)
                            } else {
                                css("top", 0)
                            }
                            html("<img border=0 src=" + currImg.attr("src") + ">")
                        } else {
                            css("top", 0);
                            html("<img border=0 src=" + currImg.attr("src") + " height=" + windowHeight + ">")
                        }
                    } else {
                        var currImgChangeHeight = (currImgHeight * windowWidth) / currImgWidth;
                        if (currImgChangeHeight < windowHeight) {
                            var topHeight = (windowHeight - currImgChangeHeight) / 2;
                            if (topHeight > 35) {
                                topHeight = topHeight - 35;
                                css("top", topHeight)
                            } else {
                                css("top", 0)
                            }
                            html("<img border=0 src=" + currImg.attr("src") + " width=" + windowWidth + ";>")
                        } else {
                            css("top", 0);
                            html("<img border=0 src=" + currImg.attr("src") + " width=" + windowWidth + "; height=" + windowHeight + ">")
                        }
                    }
                }
                tempContainer.click(function() {
                    $(this).remove();
                    coverLayer(0)
                })
            })
        })
} else {}
function coverLayer(tag) {
    with($(".over")) {
        if (tag == 1) {
            css("height", $(document).height());
            css("display", "block");
            css("opacity", 1);
            css("background-color", "#191919")
        } else {
            css("display", "none")
        }
    }
};